package controller;

import controller.result.VueJsonResult;
import lombok.Data;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Data
@RestController
public class VueTestAction {

    @RequestMapping(value = "/vueGetString.action", method = RequestMethod.GET)
    public String vueGetString(@RequestParam("param1") String param1, @RequestParam("param2") String param2) {
        System.out.println(param1 + " --> " + param2);
        return "HelloVue!";
    }

    @RequestMapping(value = "/vueGetJson.action", method = RequestMethod.GET)
    public VueJsonResult vueGetJson(@RequestParam("param1") String param1, @RequestParam("param2") String param2) {
        System.out.println(param1 + " --> " + param2);
        return new VueJsonResult(3, "Hello!", "Java!");
    }

    @RequestMapping(value = "/vuePostString.action", method = RequestMethod.POST)
    public String vuePostString(@RequestBody Map<String, String> resultMap) {
        for (Map.Entry<String, String> entry : resultMap.entrySet()) {
            System.out.println(entry.getKey() + " --> " + entry.getValue());
        }
        return "I'm good,ok!";
    }
}
